<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
      <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  </head>
  <script>var index;
  </script><body>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <input type="hidden" id="idCulture" name="idCulture" value="${id}"/>
                <label for="title" class="layui-form-label">
                    <span class="x-red">*</span>标题
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="title" name="title" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" value="">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="content" class="layui-form-label">
                    <span class="x-red">*</span>内容
                </label>
                <div class="layui-input-inline" style="width: 745px;">
                        <textarea id="content"  name="content" style="display: none;"
                                  class="layui-hide"></textarea>
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="content" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    提交
                </button>
            </div>
      </form>
    </div>
    <script>
        layui.use('layedit', function(){

        });

        layui.use(['form','layer','layedit'], function(){


            var layedit = layui.layedit;
            layedit.set({
                uploadImage: {
                    url: path + '/pc/upload/uploadFile' //接口url
                    ,type: 'post' //默认post
                }
            });
            var index = layedit.build('content');//建立编辑器
            var params = {"idCulture":$("#idCulture").val()};
            ajaxFun('get','/pc/culture/getCulture',params,function(data){
                if(data.code != 0){
                    alertFun(data);
                }else{
                    $("#title").val(data.data.title);
                    $("#content").html(data.data.content);
                    layedit.setContent(index,data.data.content);
                }
            })

            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer, layedit = layui.layedit;
          //自定义验证规则
          form.verify({
//            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            /*,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }*/
          });//监听提交
          form.on('submit(add)', function(t){
            var params = {
                idCulture:$("#idCulture").val(),
                title:$("#title").val(),
                content:layedit.getContent(index)
            }
            if(true){
                ajaxFun('post','/pc/culture/updateCulture',params,function(data){
                    if(data.code != 0){
                        alertFun(data);
                    }else{
                        window.location.href= path + "/modules/culture/list.html";
                        console.log("success !");
                    }
                })
            }
            return false;
          });});
    </script></body></html>